package com.taxshare.api.common;


import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.unit.DataSize;
import org.springframework.web.client.RestTemplate;

import javax.servlet.MultipartConfigElement;
import java.time.Duration;


/**
 * 公共bean生成
 *
 * @author chenxd
 * @date 2019/01/02
 */
@Configuration
@SuppressWarnings("all")
public class ApplicationConfig {
    
    @Bean
    @LoadBalanced
    RestTemplate restTemplate() {
        return new RestTemplate();
    }


    @Bean("customRest")
    RestTemplate customTemplate(RestTemplateBuilder restTemplateBuilder) {
        return restTemplateBuilder.setConnectTimeout(Duration.ofMillis(10000)).setReadTimeout(Duration.ofMillis(30000)).build();
    }
}
